<template>
  <div class="BusBusinessOpportunityChangeList">
    <!-- table区域-begin -->
    <a-tabs defaultActiveKey="1">
      <a-tab-pane :tab="index? index + '、' + '变更记录':'变更记录'" key="1">
        <a-table
          ref="table"
          size="middle"
          :scroll="{ x: true }"
          bordered
          rowKey="id"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          class="j-table-force-nowrap"
          @change="handleTableChange"
        >
          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>
          <template slot="imgSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
            <img
              v-else
              :src="getImgView(text)"
              height="25px"
              alt=""
              style="max-width: 80px; font-size: 12px; font-style: italic"
            />
          </template>
          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
            <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
              下载
            </a-button>
          </template>

          <span slot="action" slot-scope="text, record">
            <a @click="handleEdit(record)">编辑</a>
            <a-divider type="vertical" />
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a style="color:red">删除</a>
            </a-popconfirm>
          </span>
        </a-table>
      </a-tab-pane>
    </a-tabs>
    <busBusinessOpportunityChange-modal
      ref="modalForm"
      @ok="modalFormOk"
      :mainId="mainId"
    ></busBusinessOpportunityChange-modal>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import BusBusinessOpportunityChangeModal from './modules/BusBusinessOpportunityChangeModal'
import { getAction } from '@api/manage'

export default {
  name: 'BusBusinessOpportunityChangeList',
  mixins: [JeecgListMixin],
  components: { BusBusinessOpportunityChangeModal },
  props: {
    mainId: {
      type: String,
      default: '',
      required: false,
    },
    dataType: {
      type: String,
      default: '',
      required: false,
    },
    index: {
      type: Number,
    },
  },
  watch: {
    mainId: {
      immediate: true,
      handler(val) {
        if (!this.mainId) {
        } else {
          this.queryParam['opportunityId'] = val
          this.loadData()
        }
      },
    },
  },
  data() {
    return {
      description: '客户商机管理页面',
      disableMixinCreated: true,
      showChangeTable: false,
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 45,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '变更人',
          align: 'center',
          dataIndex: 'createBy',
          width: '5%',
        },
        {
          title: '变更时间',
          align: 'center',
          dataIndex: 'createTime',
          width: '7%',
        },
        {
          title: '变更内容',
          align: 'left',
          dataIndex: 'content',
        },
      ],
      url: {
        list: '/sys/dataChangeRecord/queryByDataIdAndType',
        delete: '/bussiness/busBusinessOpportunity/deleteBusBusinessOpportunityChange',
        deleteBatch: '/bussiness/busBusinessOpportunity/deleteBatchBusBusinessOpportunityChange',
        exportXlsUrl: '/bussiness/busBusinessOpportunity/exportBusBusinessOpportunityChange',
        importUrl: '/bussiness/busBusinessOpportunity/importBusBusinessOpportunityChange',
      },
      dictOptions: {
        stage: [],
        signPossibility: [],
        type: [],
        source: [],
      },
      superFieldList: [],
    }
  },
  created() {
    this.loadData()
  },
  computed: {
    importExcelUrl() {
      return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`
    },
  },
  methods: {
    loadData() {
      getAction(this.url.list, { dataId: this.mainId, type: this.dataType }).then((res) => {
        this.dataSource = res.result
      })
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
<style>
.BusBusinessOpportunityChangeList .ant-table-placeholder {
  padding: 0;
}
.BusBusinessOpportunityChangeList .ant-empty-normal {
  margin: 15px 0;
}
</style>
